#include "cshowapp.h"

#include <buola/dbus/cproxy.h>

namespace buola { namespace show {

CShowApp::CShowApp()
    :   dbus::CObject<CShowApp>("/org/buola/Show")
{
}

CShowApp::~CShowApp()
{

}

bool CShowApp::Activate()
{
    if(dbus::get_session_bus()->RegisterService("org.buola.BCal")) return true;

    //if we can't register... recycle existing window
    dbus::CProxy lProxy(dbus::get_session_bus(),"org.buola.BCal","/org/buola/BCal");
    lProxy.CallIgnore("org.buola.BCal","RaiseWindow");

    return false;
}

bool CShowApp::Start()
{
    if(!Activate()) return false;
    CApp::Start();

    PMainWindow lWindow=new CMainWindow;

    for(const std::string &a : cmd_line().Args())
    {
        lWindow->Open(io::file(a));
    }

    lWindow->Map();
    
    return true;
}

/*namespace show*/ } /*namespace buola*/ }
